// db.account.update({"id": 123}, {$inc: {"balance": -50}})
// db.account.update({"id": 124}, {$inc: {"balance": 50}})
session = db.getMongo().startSession({readPreference: {mode:"primary"}});
coll1 = session.getDatabase("test").account;
session.startTransaction({readConcern: {level:"local"}, writeConcern:{w:"majority"}});
try {
    coll1.update({"id": 124}, {$inc: {"balance": -50}});
    sleep(10000);
    coll1.update({"id": 123}, {$inc: {"balance": 50}});
} catch(error) {
    session.abortTransaction();
    throw error;
}

session.commitTransaction();
session.endSession();


